<include file="Public:header" />
<div class="container">
	<div class="page-header">
		<h4>{:L('SYSTEM_SETTING')}</h4>
	</div>
	<include file="Public:alert" />	
	<div class="tabbable">
		<ul class="nav nav-tabs">
			<li><a href="{:U('setting/defaultInfo')}">{:L('BASIC_SYSTEM_SETTING')}</a></li>
			<li class="active"><a href="{:U('setting/smtp')}">{:L('SMTP_SETTING')}</a></li>
			<li><a href="{:U('setting/fields')}">{:L('CUSTOMIZING_FIELDS_SETTING')}</a></li>		
			<li><a href="{:U('navigation/setting')}">{:L('SYSTEM_NAVIGATION_SETTING')}</a></li>
			<li><a href="{:U('setting/weixin')}">{:L('WHCHAT_SETTING')}</a></li>
		</ul>
		<div class="row">
		<form class="form-horizontal" action="{:U('setting/smtp')}" method="post">
			<table class="span6 table">
				<tbody>
					<tr>
						<th colspan="2">{:L('SMTP_BASIC_SETTING')}</th>
					</tr>
					<tr>
						<td class="tdleft">{:L('EMAIL_ADDRESS')}</td>  
						<td>
							<input name="address" id="address" type="text" value="{$smtp['MAIL_ADDRESS']}"/> <span style="color:red;">{:L('MUST_FILL_IN')}</span>
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('SMTP_SERVER_ADDRESS')}</td>  
						<td>
							<input value="{$smtp['MAIL_SMTP']}" id="smtp" name="smtp" type="text"> <span style="color:red;">{:L('MUST_FILL_IN')}</span>&nbsp;&nbsp;&nbsp;&nbsp;<input value="ssl" id="secure" name="secure" type="checkbox" <if condition="$smtp['MAIL_SECURE'] == 'ssl'">checked="checked"</if>> SSL
						</td>
					</tr>
                    <tr>
						<td class="tdleft">{:L('SMTP_SERVER_PORT')}</td>  
						<td>
							<input value="{$smtp['MAIL_PORT']|default=25}" id="port" name="port" type="text"> <span style="color:red;">{:L('MUST_FILL_IN')}</span>
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('LOGIN_NAME')}</td>  
						<td>
							<input value="{$smtp['MAIL_LOGINNAME']}" id="loginName" name="loginName" type="text"/> <span style="color:red;">{:L('MUST_FILL_IN')}</span>
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('PASSWORD')}</td>  
						<td>
							<input value="{$smtp['MAIL_PASSWORD']}" id="password" name="password" type="password"> <span style="color:red;">{:L('MUST_FILL_IN')}</span>
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('TEST_EMAIL')}:</td>  
						<td>
							<input name="test_email" id="test_email" type="text"/> &nbsp; <input class="btn btn-mini" id="test" name="submit" type="button" value="{:L('TEST')}">
						</td>
					</tr>
					<tr>
						<th colspan="2">{:L('SMS_CONFIGURATION_INFORMATION')}</th>
					</tr>
					<tr>
						<td class="tdleft">{:L('THE_USER_NAME_TEXT_INTERFACE')}</td>  
						<td>
							<input name="uid" id="uid" type="text" value="{$sms['uid']}"/>
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('SMS_INTERFACE_PASSWORD')}</td>  
						<td>
							<input value="{$sms['passwd']}" id="passwd" name="passwd" type="password">
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('CUSTOMER_MESSAGE_SIGNATURE')}</td>  
						<td>
							<input value="{$sms['sign_name']}" maxlength="8" id="sign_name" name="sign_name" type="text">
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('INTERNAL_NOTIFICATION_MESSAGE_SIGNATURE')}</td>  
						<td>
							<input value="{$sms['sign_sysname']}" maxlength="8" id="sign_sysname" name="sign_sysname" type="text">
						</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('TEST_PHONE')}</td>  
						<td>
							<input name="test_sms_phone" id="test_sms_phone" type="text"/> &nbsp; <input class="btn btn-mini" id="test_sms_btn" type="button" value="{:L('SEND_TEST_SMS')}"/>
						</td>
					</tr>
					
					<tr>
						<td>&nbsp;</td>
						<td>
							<input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
		</div>
	</div> <!-- End #main-content -->
</div>
<script type="text/javascript">	
	$('#test').click(
		function(){
			address = $('#address').val();
			smtp = $('#smtp').val();
			port = $('#port').val();
			secure = $('#secure:checked').val();
			name = $('#loginName').val();
			pw = $('#password').val();
			email = $('#test_email').val();
			if(address !='' && smtp !='' && port !='' && name!='' && pw!='' && email!=''){
				$.post('{:U("setting/smtp")}',
				{   address:address,
					smtp:smtp,
					port:port,
					secure:secure,
					loginName:name,
					password:pw,
					test_email:email},
				function(data){
					alert(data.info);
				},
				'json');
			} else {
				alert('{:L("PLEASE_FILL_IN_COMPLETE_INFORMATION")}');
			}
		}
	);
	$('#test_sms_btn').click(
		function(){
			uid = $('#uid').val();
			passwd = $('#passwd').val();
			phone = $('#test_sms_phone').val();
			if(uid !='' && passwd !='' && phone !=''){
				$.post('{:U("setting/smtp")}',
				{   uid:uid,
					passwd:passwd,
					phone:phone},
				function(data){
					alert(data.info);
				},
				'json');
			} else {
				alert('{:L("PLEASE_FILL_IN_COMPLETE_INFORMATION")}');
			}
		}
	);
</script>
<include file="Public:footer" />	